﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.ComponentModel;

namespace ServerAnalysisReport
{
    /*
     * Collection Class to help use DataBinding
     * Will be used to attach to DataGridViewer
     */
    class ServerNamesCollections : IEnumerable, IEnumerator
    {
 
        // PRIVATE MEMBERS 
        private Server[] ServerArray; 
        private int intCurrent = 0;        // Current Position (for Enumerator) 
        private int intNumServers = 0;    // Number of Books Currently in the Library 
        //private const int MAXSERVERS = 100;    // Max number of books held by the Library 
        //private int MAXSERVERS = 100;
        private ArrayList serverlistingAR;
        // CONSTRUCTORS 
        //Supply Max Number (read the array size..)
        public ServerNamesCollections() 
        {
            serverlistingAR = new ArrayList(ServerAnalysisReport.Properties.Settings.Default.ServerListings.Split(','));
            ServerArray = new Server[serverlistingAR.Count]; 
        } 

        public static BindingList<Server> serverlist = new BindingList<Server>();

        public BindingList<Server> ServerInfo
        {
            set { serverlist = value; }  // <<  No Change When Commented Out
            get { return serverlist; }
        }       

        // METHODS 
        public void AddServer(Server server) 
        {
            ServerArray[intNumServers] = server;
            intNumServers++;
        } 

        public IEnumerator GetEnumerator() 
        { 
            return (IEnumerator)this; 
        } 

        public bool MoveNext() 
        { 
            if (intCurrent < intNumServers) 
            { 
                intCurrent++; 
                return true; 
            } 
            else 
            { 
                return false; 
            } 

        } 

        public object Current 
        { 
            get { return ServerArray[intCurrent-1]; } 
        } 

        public void Reset() 
        { 
            intCurrent = 0; 
        }

    }

    class Server
    {
        string localservername;
        public Server(string suppliedservername)
        {
            localservername = suppliedservername;
        }
        public string Servername
        {
            get
            {
                return localservername;
            }
            set
            {
                localservername = value;
            }
        }
        public override string ToString()
        {
            return localservername;
        }
    }

    


}
